package com.doit.day02;

import com.doit.day01.JedisUtil;
import redis.clients.jedis.Jedis;

import java.util.ArrayList;
import java.util.HashMap;

public class WordCount {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("hadoop,hadoop,hive,hadoop,hive,hi,hi");
        list.add("hadoop,hadoop,hive,hadoop,hive,hi,hi");
        list.add("hadoop,hadoop,hive,hadoop,hive,hi,hi");
        list.add("hadoop,hadoop,hive,hadoop,hive,hi,hi");
        list.add("hadoop,hadoop,hive,hadoop,hive,hi,hi");
        list.add("hadoop,hadoop,hive,hadoop,hive,hi,hi");
        list.add("hadoop,hadoop,hive,hadoop,hive,hi,hi");

        //做单词统计，然后将结果都存在redis中  key wc value的数据类型是什么？？？？
        //首先获取到redis的对象
        Jedis jedis = JedisUtil.getJedis();

        for (String line : list) {
            String[] arr = line.split(",");
            for (String word : arr) {
                //我要将单词一个个的都丢到hash结构中去
//                jedis.hincrBy("wc",word,1);
                //用sorted set 这个结构
                jedis.zincrby("wc",1,word);
            }
        }



    }
}
